import { Request, Response } from 'express';
import moment from 'moment';

export default {
  'GET /api/roles': (req: Request, res: Response) => {
    console.log(req.query);
    const { current, pageSize } = req.query;
    const dataSource = [
      {
        key: '1',
        desc: '超级管理员',
        role_id: 'admin',
        role_name: '超级管理员',
        status: 1,
        updatedAt: moment().format('YYYY-MM-DD'),
        createdAt: moment().format('YYYY-MM-DD'),
      },
      {
        key: '2',
        desc: '普通员工',
        role_id: 'test1',
        role_name: '普通账号',
        status: 1,
        updatedAt: moment().format('YYYY-MM-DD'),
        createdAt: moment().format('YYYY-MM-DD'),
      },
      {
        key: '3',
        desc: '测试账号',
        role_id: 'test2',
        role_name: '测试账号',
        status: 1,
        updatedAt: moment().format('YYYY-MM-DD'),
        createdAt: moment().format('YYYY-MM-DD'),
      },
    ];
    const result = {
      data: dataSource,
      total: dataSource.length,
      success: true,
      pageSize,
      current: parseInt(`${current}`, 10) || 1,
    };
    return res.json(result);
  },
};
